package cycling.taxi.com.ui.fragment;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cycling.taxi.com.R;
import cycling.taxi.com.base.BaseFragment;
import cycling.taxi.com.base.LoadDataUi;
import cycling.taxi.com.bean.NoticeInfo;
import cycling.taxi.com.bean.ShopInfo;
import cycling.taxi.com.entity.Tips;
import cycling.taxi.com.person.ExitApplication;
import cycling.taxi.com.utils.LogUtil;
import cycling.taxi.com.utils.SPUtil;
import cycling.taxi.com.utils.ToastUtil;
import cycling.taxi.com.utils.Urls;

/**
 * Created by Administrator on 2017/5/4.
 */
public class RepairFrgt extends BaseFragment implements View.OnClickListener{

    private EditText repair_content;
    private Button repair_btn;
    private RequestQueue queue;
    private String content;
    private String status;
    private EditText name;
    @Override
    protected View OnInitSuccessView() {
        View view = LayoutInflater.from(this.getContext()).inflate(R.layout.fragment_repair_frgt, null);
        initUI(view);
        initClick();
        return view;
    }
    private void initUI(View view) {
        repair_content=(EditText)view.findViewById(R.id.repair_content);
        repair_btn=(Button)view.findViewById(R.id.repair_btn);
        name=(EditText)view.findViewById(R.id.name_et);
    }
    private void initClick(){
        repair_btn.setOnClickListener(this);
        queue= Volley.newRequestQueue(this.getContext());
    }



    @Override
    protected LoadDataUi.Result doInbackground() {
        return LoadDataUi.Result.SUCCESS;
    }

    @Override
    public void onClick(View v) {
        if(v.getId()==R.id.repair_btn){
            volleyPost();
        }
    }
    public void volleyPost(){
        //String path= "http://192.168.1.100:8080/CyclingBgTV1/appNotice/repair.dop";
        String path = Urls.getRepair();
        StringRequest request = new StringRequest(Request.Method.POST,path, new Response.Listener<String>() {
            @Override
            public void onResponse(String s) {
                status=s;
                if(status.equals("1"))
                    ToastUtil.getInstance().toast("提交成功");
            }
        },null){
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String,String > map= new HashMap<String,String>();
                String beanJson= SPUtil.getInstance().getData("beanJson");
                String verhicledata=SPUtil.getInstance().getData("verhicledata");
                content=repair_content.getText().toString();
                map.put("name",name.getText().toString());
                map.put("xinghao",name.getText().toString());
                map.put("content",content);
                map.put("beanJson",beanJson);
                map.put("verhicledata",verhicledata);
                return map;
            }
        };
        queue.add(request);
    }
}
